Implement the first part of N4258: 'Cleaning up noexcept in the Library'. This patch deals with swapping containers, and implements a more strict noexcept specification (a conforming extension) than the standard mandates. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242056 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/list b/include/list index d39f076..14201a8 100644 --- a/include/list +++ b/include/list
@@ -118,8 +118,7 @@ void resize(size_type sz, const value_type& c); void swap(list&) - noexcept(!allocator_type::propagate_on_container_swap::value || - __is_nothrow_swappable<allocator_type>::value); + noexcept(allocator_traits<allocator_type>::is_always_equal::value); // C++17 void clear() noexcept; void splice(const_iterator position, list& x); @@ -593,8 +592,12 @@ } void swap(__list_imp& __c) - _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value); +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT; +#else + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable<allocator_type>::value); +#endif _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __list_imp& __c) @@ -611,24 +614,6 @@ private: _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__node_allocator& __x, __node_allocator& __y) - _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value) - {__swap_alloc(__x, __y, integral_constant<bool, - __node_alloc_traits::propagate_on_container_swap::value>());} - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, true_type) - _NOEXCEPT_(__is_nothrow_swappable<__node_allocator>::value) - { - using _VSTD::swap; - swap(__x, __y); - } - _LIBCPP_INLINE_VISIBILITY - static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, false_type) - _NOEXCEPT - {} - - _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __list_imp& __c, true_type) { if (__node_alloc() != __c.__node_alloc()) @@ -728,15 +713,19 @@ template <class _Tp, class _Alloc> void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) - _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value) +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT +#else + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || + __is_nothrow_swappable<allocator_type>::value) +#endif { _LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value || this->__node_alloc() == __c.__node_alloc(), "list::swap: Either propagate_on_container_swap must be true" " or the allocators must compare equal"); using _VSTD::swap; - __swap_alloc(__node_alloc(), __c.__node_alloc()); + __swap_allocator(__node_alloc(), __c.__node_alloc()); swap(__sz(), __c.__sz()); swap(__end_, __c.__end_); if (__sz() == 0) @@ -972,8 +961,12 @@ _LIBCPP_INLINE_VISIBILITY void swap(list& __c) +#if _LIBCPP_STD_VER >= 14 + _NOEXCEPT +#else _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value) +#endif {base::swap(__c);} _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT {base::clear();}